'use strict';

const Controller = require('egg').Controller;

class FileController extends Controller {
  async upload() {
    const parts = this.ctx.multipart();
    const part = await parts();
    const data = await this.ctx.service.file.upload(part);

    this.ctx.body = {
      code: 0,
      data: {
        url: data,
      },
    };
  }
}

module.exports = FileController;
